<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
	if(isset($_POST['Submit']))
	{
		$vesselName  = 	isset($_POST['vesselName']) && $_POST['vesselName'] !='' ? $_POST['vesselName'] : "";
		
	  $insertVessel = "INSERT INTO  vesselmaster(vesselName)VALUES('".$vesselName."')";
	  $insertVesselRes = mysql_query($insertVessel);
	  if(!$insertVesselRes)
	  {
	  	echo "Insert Fail";
	  }
	  else
	  {
	  	header("Location:vesselMaster.php");
	  }
	}
	
	$i=0;
	$vesselArray = array();
	$selectvessel = "SELECT vesselId,vesselName
	                   FROM  vesselmaster";
  $selectvesselRes = mysql_query($selectvessel);
  while($vesselRow = mysql_fetch_array($selectvesselRes))
  {
  	$vesselArray[$i]['vesselId']   = $vesselRow['vesselId'];
  	$vesselArray[$i]['vesselName'] = $vesselRow['vesselName'];
  	$i++;
  }
}
include("./bottom.php");
$smarty->assign("vesselArray",$vesselArray);
$smarty->display("vesselMaster.tpl");
?>